package com.ai.consumer.BIConsumer;

import com.ai.common.constant.BIMQConstant;
import com.ai.consumer.mamage.AIManager;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;

import static com.ai.common.Enum.AIModel.BIMODEL;

@Component
@Slf4j
public class BiMessageConsumer {
    @Resource
    private AIManager aiManager;
    @RabbitListener(queues = {BIMQConstant.AI_QUEUE_NAME},ackMode = "MANUAL")
    public void receive(String message, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) throws IOException {
        log.info("消息传递的参数为：{}",message);
        String result = aiManager.doChart(BIMODEL.getModelID(), message);
        log.info("AI响应结果:{}",result);
    }
}
